home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-03 | 3.3 KB | 101 lines | [TEXT/R*ch] |
- (* Real -- SML Standard Library *)
-
- type real = real
-
- exception Div
- and Overflow
-
- val ~ : real -> real
- val + : real * real -> real
- val - : real * real -> real
- val * : real * real -> real
- val / : real * real -> real
- val abs : real -> real
- val min : real * real -> real
- val max : real * real -> real
- val sign : real -> int
- val compare : real * real -> ordering
-
- val sameSign : real * real -> bool
- val toDefault : real -> real
- val fromDefault : real -> real
-
- val floor : real -> int
- val ceil : real -> int
- val trunc : real -> int
- val round : real -> int
- val real : int -> real
-
- val > : real * real -> bool
- val >= : real * real -> bool
- val < : real * real -> bool
- val <= : real * real -> bool
-
- val toString : real -> string
- val fromString : string -> real option
- val scan : {getc : 'a -> (char * 'a) option} -> 'a -> (real * 'a) option
- val fmt : StringCvt.realfmt -> real -> string
-
- (* [~, *, /, +, -, >, >=, <, <=, abs] are the usual operations
- on reals, as prescribed by the Definition.
-
- [min(x, y)] is the smaller of x and y.
-
- [max(x, y)] is the larger of x and y.
-
- [sign x] is ~1, 0, or 1, according as x is negative, zero, or positive.
-
- [compare(x, y)] returns LESS, EQUAL, or GREATER, according
- as x is less than, equal to, or greater than y.
-
- [sameSign(x, y)] is true iff sign x = sign y.
-
- [toDefault x] is x.
-
- [fromDefault x] is x.
-
- [floor r] is the largest integer <= r (rounds towards minus infinity).
-
- [ceil r] is the smallest integer >= r (rounds towards plus infinity).
-
- [trunc r] is numerically largest integer between r and zero
- (rounds towards zero).
-
- [round r] is the integer nearest to r. In case of a tie, rounds to
- nearest numerically larger integer. NOTE: This isn't the required
- behaviour: it should round to nearest even integer in case of a tie.
-
- [fmt spec r] returns a string representing r, in the format
- specified by spec.
-
- spec description C printf
- ---------------------------------------------------------------
- SCI NONE scientific, 6 digits after point %e
- SCI (SOME n) scientific, n digits after point %.ne
- FIX NONE fixed-point, 6 digits after point %f
- FIX (SOME n) fixed-point, n digits after point %.nf
- GEN NONE auto choice, 12 significant digits %.12g
- GEN (SOME n) auto choice, n significant digits %.ng
-
- [toString r] returns a string representing r, with automatic choice
- of format according to the magnitude of r.
- Equivalent to (fmt (GEN NONE) r).
-
- [fromString s] returns SOME(r) if a floating-point numeral can be
- scanned from a prefix of string s, ignoring any initial whitespace;
- returns NONE otherwise. The valid forms of floating-point numerals
- are described by:
- [+~-]?(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][+~-]?[0-9]+)?
-
- [scan {getc} charsrc] attempts to scan a floating-point number from
- the character source charsrc, using the accessor getc, and ignoring
- any initial whitespace. If successful, it returns SOME(r, rest)
- where r is the number scanned, and rest is the unused part of the
- character source. The valid forms of floating-point numerals
- are described by:
- [+~-]?(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][+~-]?[0-9]+)?
- *)
-
-
-
-